﻿<Window x:Class="SpringBeansEditor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:editors="clr-namespace:SpringBeansEditor.Editors"
        xmlns:helpers="clr-namespace:SpringBeansEditor.GUIHelpers"
        Title="MainWindow" Height="auto" Width="auto">
    <Window.Resources>
        <Style x:Key="AttrNameStyle">
            <!--
            <Setter Property="Control.Background" Value="BlueViolet" />
            <Setter Property="Control.Foreground" Value="White" />
            -->

            <Setter Property="TextBlock.FontWeight" Value="Bold" />
        </Style>

        <HierarchicalDataTemplate
        DataType="spr:objects"
           
        ItemsSource="{Binding XPath=spr:object}"
            >
            <TextBlock
            Text="Objects" />
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate
        DataType="spr:object"
           
        ItemsSource="{Binding XPath=spr:property}"
          
            >
            <StackPanel Orientation="Horizontal">
                <TextBlock Style="{StaticResource AttrNameStyle}">
ID:</TextBlock>
                <TextBlock
            Text="{Binding XPath=@id}" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <DataTemplate
        DataType="spr:property">
            <StackPanel Orientation="Horizontal">
                <TextBlock  Style="{StaticResource AttrNameStyle}">Name:</TextBlock>
                <TextBlock
            Text="{Binding XPath=@name}" />
                <TextBlock Style="{StaticResource AttrNameStyle}">Value:</TextBlock>
                <TextBlock
            Text="{Binding XPath=@value}" />
                <TextBlock Style="{StaticResource AttrNameStyle}">Ref:</TextBlock>
                <TextBlock
            Text="{Binding XPath=@ref}" />
            </StackPanel>
        </DataTemplate>
       
        <XmlNamespaceMappingCollection x:Key="namespaceMappings">
            <XmlNamespaceMapping   Uri="http://www.springframework.net" Prefix="spr"/>
        </XmlNamespaceMappingCollection>

        <XmlDataProvider DataChanged="XmlDataProvider_DataChanged"
        x:Key="dataxml" XmlNamespaceManager="{StaticResource namespaceMappings}"
        >
        </XmlDataProvider>
    </Window.Resources>

    <ScrollViewer Grid.Column="0" Height="auto">
        <Grid>
            <TabControl>
                <TabItem Header="Assemblies for Classes used in XML">
                    <helpers:AssemblyLoader ></helpers:AssemblyLoader>
                </TabItem>
                <TabItem Header="Objects in XML">
                    <StackPanel Orientation="Vertical">

                        <helpers:LoadXML x:Name="LoadXMLForm" Height="120"></helpers:LoadXML>

                        <StackPanel Orientation="Horizontal" Height="auto">
                            <TextBlock>Commands:</TextBlock>
                            <StackPanel Orientation="Horizontal" Name="CommandsPanel">

                            </StackPanel>
                        </StackPanel>

                        <Grid Margin="4,4,4,4" Height="auto">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="300" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ScrollViewer Grid.Column="0" Height="auto">
                                <TreeView SelectedItemChanged="treeview_SelectedItemChanged"
                Width="Auto"
                Name="treeview"
                                        
                ItemsSource="{Binding Source={StaticResource dataxml}, XPath=//spr:objects}"
                                          Binding.XmlNamespaceManager="{StaticResource namespaceMappings}" />
                            </ScrollViewer>
                            <ScrollViewer Grid.Column="1">
                                <Grid Name="EditorPanel" >
                                    <editors:BeanEditor x:Name="BeanEditorForm" OnBeanChanged="OnBeanChanged" />
                                    <editors:PropertyEditor  x:Name="PropertyEditorForm" />
                                </Grid>
                            </ScrollViewer>
                        </Grid>
                    </StackPanel>
                </TabItem>
            </TabControl>


        </Grid>
    </ScrollViewer>

</Window>
